<template>
    <div>
        <van-sticky>
            <van-nav-bar :title="user.name" right-text="设置" @click-right="onUser" />
        </van-sticky>
        <van-cell @click="onArticle()" title="我的文章列表" />
        <van-cell @click="onMyAttention()" title="我的关注列表" />
        <van-cell @click="onAttentionByMy()" title="谁在关注我" />
        <van-cell @click="onShare()" title=" 我的分享" />
        <van-cell @click="onImg()" title="我的图床" />
        <van-cell @click="onCommodity()" title="我的商品" />
        <van-button v-if="loginIs==0" round block type="info" @click="onSubmit">
            退出登录
        </van-button>
        <van-button v-if="loginIs==1" round block type="info" @click="onSubmit2">
            登录
        </van-button>
    </div>
</template>

<script>
export default {
    name: 'editorElem',
    data() {
        return {
            loginIs: 1,
            editorContent: '',
            user: {}
        }
    },
    //props: ['catchData'],    //接收父组件的方法
    mounted() {
        this.getDataList()
    },
    methods: {
        async getDataList() {
            let res = await this.$http.getMyUser()
            if (res !== undefined && res.meta.status == 200) {
                this.user = res.data
                this.loginIs = 0
            }
            if (res !== undefined && res.meta.status == 401) {
                this.loginIs = 1
            }
        },
        onUser() {
            this.$router.push({ path: this.redirect || '/user' })
        },
        onArticle() {
            this.$router.push({ path: this.redirect || '/articleList', query: { id: this.user.userId } })
        },
        onShare() {
            this.$router.push({ path: this.redirect || '/shareList', query: { id: this.user.userId } })
        },
        onImg() {
            this.$router.push({ path: this.redirect || '/imgList', query: { id: this.user.userId, name: this.user.name, onIs: 0 } })
        },
        onCommodity() {
            this.$router.push({ path: this.redirect || '/commodityList', query: { id: this.user.userId, name: this.user.name } })
        },
        onMyAttention() {
            this.$router.push({ path: this.redirect || '/attentionList', query: { id: this.user.userId, name: this.user.name, onIs: 0 } })
        },
        onAttentionByMy() {
            this.$router.push({ path: this.redirect || '/attentionList', query: { id: this.user.userId, name: this.user.name, onIs: 1 } })
        },
        async onSubmit() {
            this.user.name = "请登录"
            this.$http.loginOut()
            this.$router.push({ path: this.redirect || '/' })
        },
        async onSubmit2() {
            this.$router.push({ path: this.redirect || '/login' })
        },
    }
}
</script>

<style >
</style>